package com.klikmee.sms.cef.bulk;

import com.klikmee.sms.core.commons.exceptions.ErrorInfo;
import com.klikmee.sms.core.commons.exceptions.ErrorInfo.ErrorType;
import com.klikmee.sms.core.commons.exceptions.ErrorInfo.Severity;
import com.klikmee.sms.core.commons.exceptions.ServiceException;
/**
 * errors that occure during sending of bulk exceptons 
 *
 */
public class SendBulkException extends ServiceException{

	public static final String SEND_BULK_URL = "SEND_BULK_URL";
	public SendBulkException() {
		super();
	}

	public SendBulkException(String message, Throwable cause) {
		super( message, cause );
	}

	public SendBulkException(String message) {
		super( message );
	}
	
	/**
	 * Factory method for creating instance of obj in fast and clean way.
	 * @param url http handler url used to send bulk messages
	 * @param cause root cause of the exception
	 * @param contextId context in which error occurred, usually the caller method.  
	 * @return instance of the {@link SendBulkException}
	 */
	public static SendBulkException create(String url, Throwable cause, String contextId){
		SendBulkException sendBulkException = new SendBulkException();
		ErrorInfo errorInfo = sendBulkException.addInfo();
		
		errorInfo.setSeverity( Severity.FATAL );
		errorInfo.setCause( cause );
		errorInfo.setContextId( contextId );
		errorInfo.setErrorType( ErrorType.CLIENT );
		errorInfo.getParameters().put( SendBulkException.SEND_BULK_URL, url);
		
		return sendBulkException;
	}
}
